package com.store.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.store.app.R;
import com.store.app.bean.SearchSubBean;

import java.util.List;

/**
 * Created by Administrator on 2016/11/1.
 */

public class SearchSubAdapter extends BaseAdapter {
    private List<SearchSubBean> list;
    private Context context;

    public SearchSubAdapter(Context context, List<SearchSubBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {

        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        SearchSubAdapter.ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new SearchSubAdapter.ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_search_order_sub, null);
            viewHolder.goods_title = (TextView) convertView.findViewById(R.id.goods_title);
            viewHolder.qty = (TextView) convertView.findViewById(R.id.qty);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (SearchSubAdapter.ViewHolder) convertView.getTag();
        }
        viewHolder.goods_title.setText(list.get(position).getGoods_title());
        viewHolder.qty.setText("x"+list.get(position).getQty());
        return convertView;
    }


    class ViewHolder {
        TextView goods_title;
        TextView qty;
    }
}
